const sampler_t _sampler = CLK_ADDRESS_NONE | CLK_FILTER_NEAREST | CLK_NORMALIZED_COORDS_FALSE;

__kernel
void basic_opencl_img(__global float *matrix, __read_only image2d_t v, __const int rows, __const int cols, __global float *answer) {
  int row = get_global_id(0);
  float accumulator = 0;
  int rowStart = row * cols;

  for(int col = 0; col < cols; col++) {
	int coord = col / 4;
	float4 temp = read_imagef(v, _sampler, (int2)(0,coord));
	int imgPos = col & 0x0003;
	float vecElement = 0;
	if (imgPos < 2) {
      if (imgPos == 0) vecElement = temp.x;
      else vecElement = temp.y;
	} else {
      if (imgPos == 2) vecElement = temp.z;
      else vecElement = temp.w;
	}
      accumulator += matrix[rowStart + col] * vecElement;
  }
  answer[row] = accumulator;
}